﻿using GLstudent.DAL;
using GLstudent.Models;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace GLstudent.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class teacherController : ControllerBase
    {
        private DAL_teacher teacher = new DAL_teacher();
        /// <summary>
        /// 按教师编号查询学生信息
        /// </summary>
        /// <param name="tbianhao">教师编号</param>
        /// <returns></returns>
        [HttpGet]
        public List<xueshengshitu> chaxunbianhao(string tbianhao)
        {
            return teacher.chaxunid(tbianhao);
        }
        /// <summary>
        /// 按教师编号模糊查询学生信息
        /// </summary>
        /// <param name="mohu">模糊查询输入的字符</param>
        /// <param name="tbianhao">教师编号</param>
        /// <returns></returns>
        [HttpGet]
        public List<xueshengshitu> mohuxuesheng(string mohu, string tbianhao)
        {
            return teacher.mohuxuesheng(mohu, tbianhao);
        }
        /// <summary>
        /// 按ID查询学生信息的方法
        /// </summary>
        /// <param name="id">要查询的id</param>
        /// <returns></returns>
        [HttpGet]
        public student chaxunid(int id)
        {
            return teacher.chaxunxueshengid(id);
        }
        /// <summary>
        /// 修改学生信息的方法
        /// </summary>
        /// <param name="g">与student对应类的参数</param>
        /// <returns></returns>
        [HttpPost]
        public int xiugaixueshengxinxi(student g)
        {
            return teacher.Updatexuesheng(g);
        }
        /// <summary>
        /// 删除学生信息的方法
        /// </summary>
        /// <param name="id">要删除的学生表中的id</param>
        /// <returns></returns>
        [HttpGet]
        public int shanchuxuesheng(int id)
        {
            return teacher.Deletedxuesheng(id);
        }
        /// <summary>
        /// 新增学生信息的方法
        /// </summary>
        /// <param name="zengjia">与student对应类的参数</param>
        /// <returns></returns>
        [HttpPost]
        public int xinzengxuesheng(student zengjia)
        {
            return teacher.Insertxuesheng(zengjia);
        }
        /// <summary>
        /// 按教师编号查询本班学生成绩
        /// </summary>
        /// <param name="tbianhao">教师编号</param>
        /// <returns></returns>
        [HttpGet]
        public List<chengjitongjitu> chaxunbh(string tbianhao)
        {
            return teacher.chaxuntongji(tbianhao);
        }
        /// <summary>
        /// 按教师编号模糊查询本班学生成绩
        /// </summary>
        /// <param name="mohu">模糊查询输入的字符</param>
        /// <param name="tbianhao">教师编号</param>
        /// <returns></returns>
        [HttpGet]
        public List<chengjitongjitu> mohubenbanchengji(string mohu, string tbianhao)
        {
            return teacher.mohubenbanchengji(mohu, tbianhao);
        }
        /// <summary>
        /// 按教师编号查询所任课程学生成绩
        /// </summary>
        /// <param name="tbianhao">教师编号</param>
        /// <returns></returns>
        [HttpGet]
        public List<chengjitongjitu> chaxunkc(string tbianhao)
        {
            return teacher.chaxunkechengchengji(tbianhao);
        }
        /// <summary>
        /// 按教师编号模糊查询所任课程学生学生成绩
        /// </summary>
        /// <param name="mohu">模糊查询输入的字符</param>
        /// <param name="tbianhao">教师编号</param>
        /// <returns></returns>
        [HttpGet]
        public List<chengjitongjitu> mohukechengchengji(string mohu, string tbianhao)
        {
            return teacher.mohukechengchengji(mohu, tbianhao);
        }
        /// <summary>
        /// 按教师编号查询本班学生成绩,并按照学生姓名排序
        /// </summary>
        /// <param name="tbianhao">教师编号</param>
        /// <returns></returns>
        [HttpGet]
        public List<chengjitongjitu> chaxunbhpaixu(string tbianhao)
        {
            return teacher.chaxunpaixu(tbianhao);
        }
        /// <summary>
        /// 按教师编号查询所任课程学生成绩,并按学生成绩排序
        /// </summary>
        /// <param name="tbianhao">教师编号</param>
        /// <returns></returns>
        [HttpGet]
        public List<chengjitongjitu> chaxunchengjipaixu(string tbianhao)
        {
            return teacher.chaxunkechengchengjipaixu(tbianhao);
        }
        /// <summary>
        /// 修改学生成绩的方法
        /// </summary>
        /// <param name="g">与chengji对应类的参数</param>
        /// <returns></returns>
        [HttpPost]
        public int xiugaixueshengchengji(chengji g)
        {
            return teacher.Updatexueshengchengji(g);
        }
        /// <summary>
        /// 按ID查询学生成绩的方法
        /// </summary>
        /// <param name="id">要查询的id</param>
        /// <returns></returns>
        [HttpGet]
        public chengji chaxunchengjiid(int id)
        {
            return teacher.chaxunxueshengchengjiid(id);
        }
        /// <summary>
        /// 按ID查询课程的方法
        /// </summary>
        /// <param name="id">要查询的id</param>
        /// <returns></returns>
        [HttpGet]
        public kecheng chaxunkechengid(int id)
        {
            return teacher.chaxunkechengid(id);
        }
        /// <summary>
        /// 删除学生成绩的方法
        /// </summary>
        /// <param name="id">要删除的id</param>
        /// <returns></returns>
        [HttpGet]
        public int shanchuchengji(int id)
        {
            return teacher.Deletedchengji(id);
        }
        /// <summary>
        /// 新增学生分数信息的方法
        /// </summary>
        /// <param name="zengjia">与chengji对应类的参数</param>
        /// <returns></returns>
        [HttpPost]
        public int xinzengchengji(chengji zengjia)
        {
            return teacher.Insertfenshu(zengjia);
        }
        /// <summary>
        /// 查询课程视图所有信息的方法
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public List<chakankecheng> chaxunkechengshitu()
        {
            return teacher.chaxunkechengsuoyou();
        }
        /// <summary>
        /// 模糊查询课程视图所有信息的方法
        /// </summary>
        /// <param name="mohu">模糊查询输入的字符</param>
        /// <returns></returns>
        [HttpGet]
        public List<chakankecheng> mohukechengsuoyou(string mohu)
        {
            return teacher.mohukechengsuoyou(mohu);
        }
        /// <summary>
        /// 按教师编号查询本班学生各科成绩平均分
        /// </summary>
        /// <param name="bianhao">教师编号</param>
        /// <returns></returns>
        [HttpGet]
        public List<gekepingjunfen> chaxunpingjunfen(string bianhao)
        {
            return teacher.chaxunpingjunfen(bianhao);
        }
    }
}
